home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks95 / MacsBugTV.sit / MacsBug TV / dcmd Includes / Dcmd.h next >
Text File  |  1995-06-24  |  8KB  |  194 lines

  1. /*
  2.     File:        dcmd.h
  3.  
  4.     Contains:    debugger command interface
  5.  
  6.     Copyright:    © 1988, 1994-1995 by Apple Computer, Inc., all rights reserved.
  7.  
  8.     Change History (most recent first):
  9.  
  10.          <4>     3/26/95    DAL        Added dcmdFillVersion and dcmdFillString.
  11.  
  12. */
  13.  
  14. #ifndef __dcmd__
  15. #define __dcmd__
  16.  
  17. #include <Types.h>
  18. #include <MachineExceptions.h>
  19.  
  20. // Possible requests from the debugger to the command
  21.  
  22. enum
  23. {
  24.     dcmdInit            = 0,    // Initialize the Dcmd
  25.     dcmdDoIt            = 1,    // Normal Dcmd execution
  26.     dcmdHelp            = 2,    // Display help for Dcmd
  27.  
  28.     // Requests added to MacsBug in 6.5d10 that are only sent to version 3 or newer dcmds.
  29.  
  30.     dcmdSecondaryInit    = 3,    // Second time to init after all System patches have been loaded
  31.     dcmdShutdown        = 4,    // Dcmd should remove any patches (if possible)
  32.     dcmdGetInfo            = 5        // Return dcmd version and pointer to help text
  33. };
  34.  
  35.  
  36. // Register file indices
  37.  
  38. #define D0Register 0
  39. #define D1Register 1
  40. #define D2Register 2
  41. #define D3Register 3
  42. #define D4Register 4
  43. #define D5Register 5
  44. #define D6Register 6
  45. #define D7Register 7
  46.  
  47. #define A0Register 8
  48. #define A1Register 9
  49. #define A2Register 10
  50. #define A3Register 11
  51. #define A4Register 12
  52. #define A5Register 13
  53. #define A6Register 14
  54. #define A7Register 15
  55.  
  56. #define PCRegister 16
  57. #define SRRegister 17        // SR is only 16 bits and is stored in the high word
  58.  
  59.  
  60. // Heap block types
  61.  
  62. #define freeBlock             0
  63. #define nonrelocatableBlock 1
  64. #define relocatableBlock    2
  65.  
  66.  
  67. // Structure used to pass information to and from dcmds.
  68.  
  69. typedef struct
  70. {
  71.     long                    *registerFile;    // pointer to 68K CPU register set
  72.     short                    request;        // what action we are requested to take
  73.     Boolean                    aborted;        // Set to true if the user types a key while scrolling
  74.     unsigned long            macsBugVersion;    // version of MacsBug we are running under
  75.     short                    maxCallback;    // maximum valid callback we can make
  76.     unsigned char            currentISA;        // ISA of current PC
  77.     ExceptionInformationPowerPC    *theException;    // Pointer to PowerPC machine state if ISA is PowerPC    
  78.     Ptr                        requestIOBlock;    // general-purpose input/output data block pointer
  79. } dcmdBlock;
  80.  
  81. typedef struct
  82. {
  83.     Str255        usageStr;
  84.     Str255        creditsStr;
  85.     NumVersion    dcmdVersion;
  86. } GetInfoRequestBlock;
  87. typedef GetInfoRequestBlock *GetInfoRequestBlockPtr;
  88.  
  89.  
  90. #define dcmdFillVersion(paramPtr, version)    \
  91.     * (long *) &((GetInfoRequestBlockPtr) (paramPtr)->requestIOBlock)->dcmdVersion = (version)
  92.  
  93. #define dcmdFillString(paramPtr, which, theStr)    \
  94.     BlockMoveData(theStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->which, (theStr)[0]+1)
  95.  
  96.  
  97. // Debugger routines that can be called by the command
  98.  
  99.   /* Draw the text in the Pascal string as one or more lines separated by CR's.
  100.      Each line causes the MacsBug display to be scrolled and the new line to be
  101.      drawn at the bottom. If the user types a key while scrolling then the aborted
  102.      flag is set telling the command to terminate immediately. */
  103.   pascal void dcmdDrawLine(const Str255 str);
  104.  
  105.   /* Draw the text in the Pascal string as a continuation of the current line.
  106.        CR's are not given special treatment. */
  107.   pascal void dcmdDrawString(const Str255 str);
  108.  
  109.   /* Draw a given number of characters starting from the given pointer as a 
  110.        continuation of the current line. CR's are not given special treatment. */
  111.   pascal void dcmdDrawText(StringPtr text, short length);
  112.  
  113.   /* Scrolls the MacsBug display up one line leaving a blank line at the bottom. */
  114.   pascal void dcmdScroll();
  115.  
  116.   /* Display the Pascal string in the command line area and wait for a key to be pressed.
  117.      Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  118.      key and adds it to the command line once the current command completes. Typing any
  119.      key other than Return sets the aborted flag and tells the command to terminate immediately. */
  120.   pascal Boolean dcmdDrawPrompt(const Str255 str);
  121.  
  122.   /* Get the current command line position */
  123.   pascal short dcmdGetPosition();
  124.         
  125.   /* Set the current command line position. This should only be set to a value returned 
  126.      by dcmdGetPosition. */
  127.   pascal void dcmdSetPosition(short pos);
  128.  
  129.   /* Return the next character on the command line or CR if the entire line has been scanned */
  130.   pascal short dcmdGetNextChar();
  131.         
  132.   /* Return the next character on the command line or CR if the entire line has been scanned.
  133.      However, the current command line position is not changed. */
  134.   pascal short dcmdPeekAtNextChar();
  135.  
  136.   /* Copy all characters from the command line to the parameter string until a delimiter
  137.      is found or the end of the command line is reached. A delimiter is either a space,
  138.      a comma or a CR. Both single and double quoted strings are allowed on the command
  139.      line. However, the leading and trailing quotes must be of the same type. The parameter
  140.      string is returned without the quotes. This function returns the delimiter */
  141.   pascal short dcmdGetNextParameter(Str255 str);
  142.  
  143.   /* Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  144.      This function returns the delimiter after the expression. The possible delimiters are
  145.      space, comma and CR.  Space is    not treated as a delimiter in the middle of expressions.
  146.      For instance, '1 + 2' will return    a value of 3 and the delimiter will be the char following
  147.      the 2. The return parameter 'ok' tells if the expression was parsed successfully. */
  148.   pascal short dcmdGetNextExpression(long* value, Boolean* ok);
  149.  
  150.   /* Copy the break message MacsBug displayed the last time it was entered into str.
  151.      This may contain multiple lines separated by CR's.*/
  152.   pascal void dcmdGetBreakMessage(Str255 str);
  153.         
  154.   /* Return a symbolic representation for address in str. If no symbol can be found
  155.      then an empty string is returned. The format of the symbol returned is Name+0000.
  156.      With the new compilers, the name is no longer restricted to 8 characters. */
  157.   pascal void dcmdGetNameAndOffset(long address, Str255 str);
  158.  
  159.   /* Return the trap name for the trap number. If no symbol can be found
  160.      then an empty string is returned. */
  161.   pascal void dcmdGetTrapName(short trapNumber, Str255 trapName);
  162.  
  163.   /* Return a pointer the macro name for the given value. If no macro can be found
  164.      then a nil is returned. */
  165.   pascal StringPtr dcmdGetMacroName(long value);
  166.  
  167.   /* When a debugger command is called, the debugger's world (low memory) is installed.
  168.      Commands that want to reference the user's world can swap back and forth between the
  169.      two worlds by making this call. This procedure does nothing in MacsBug. It is included
  170.      to support other debuggers that might want to take advantage of it. */
  171.   pascal void dcmdSwapWorlds();
  172.  
  173.   /* Toggle between the user and debugger displays.
  174.      The first call restores the user's actual screen.
  175.      The second call restores the debugger's screen. */
  176.   pascal void dcmdSwapScreens();
  177.  
  178.   /* Walk thru the blocks in the current heap, calling DoThis for each block. DoThis should
  179.      be a procedure of the form:
  180.                 
  181.         pascal void DoThis (long blockAddress, long blockLength, long addrOfMasterPtr,
  182.                              short blockType, Boolean locked, Boolean purgeable, Boolean resource)
  183.  
  184.      The blockAddress and blockLength pertain to the data in the heap block, not including
  185.      the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  186.      not the value of the master ptr. The blockType is defined by the constants freeBlock,
  187.      nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  188.      reflect the state of the block.    */
  189.   typedef pascal void (*DoThisPtr) (long blockAddress, long blockLength, long addrOfMasterPtr,
  190.                                      short blockType, Boolean locked, Boolean purgeable, Boolean resource);
  191.   pascal void dcmdForAllHeapBlocks (DoThisPtr DoThis);
  192.  
  193. #endif
  194.